A couple bug fixes; also fixed issue #42

A couple bug fixes; also fixed issue #42