Fixes #23 and fixes #49