Refactored to tidy up core code.
0.6.0