refactoring

lots of changes to the core code