Fixes issues #39 and #56