large cleanup, refactoring.