Main
Clean up code
Fix tests