Startup refactor and general cleanup