Fixes #27 and #31