a bunch of new code and cleanup once