Refactor parts of core into api, data
Cleanup, go fmt