Fixes #23 and #3