bug fixes #51 and #38