Fix remaining bugs

Only one bug to do with file overflow still occuring