lots of package additions and refactoring