clean up code and lay foundation