Changes to structure

...ists internally and probably added a few bugs along the way.