Major reorganization of code

This makes it a 'package'