Fix for #38 and #39