Finished a pass at code clean up
Removed duplicate code