Fixup race conditions, buffer overruns and removed file IO