Cleanup + Persistence

A general cleanup of code has been done, all IO has been switched to streams, persistence is now implemented.