Minor code cleanup
Marginally improved speed of some tests and fixed issue #60
Minor refactoring, fixes for issues #62 and #67