various fixes
improved write speed, fixed file descriptors, fixed fsync