(No external tools, so no forking of awk, sort, date, sed, mv, rm, and chown. Plus some stability improvements in terms of race conditions...)