Fix Issue #28

This PR cleans up code, and fixes any potential issues discovered in #28