Fixes #32 and #31