Fixes some ugly code. Adds a simpler file format.