Implemented features in issues #57 and #59
Cleanup for issue #58