Refactoring: rationalize dependencies and repackaging some classes