bunch of code cleanup