Fixes bugs #31 and #34.