A big commit after some code cleanup