[WIP] Cleanup and make code more readable