Lots of fixes for binary files