Refactored a lot of the file format and non-database related code into core-api