refactoring and doing some housecleaning