Main: Tighten up code, remove legacy code and comments