Bug fixes.
Fixes #15 and #2