Fix issue #49, and patches towards issue #50

I fixed issue #49, and refactored some code.

I also bumped the version to 6.65_01 as per the release instructions in preparation for issue #50.