Fixes #16. Some other minor modifications