More groundwork completed, fixed weird file reading bug caused by fseek/ftell