clean up error catching, generalize scaling, general clean up