Proposed fix for #51 and #57