Fixes #45
Some cleanup work