Fixes #10 and cleanup