Refactoring and cleanup, preparing for new data