lots of refactoring. LOTS.