Fixes #4 but creates new issues. See #27 and #28 for details.