break out reusable routines into .h file, clean out some dead lines