Fixed bugs. Fixes #14. Fixes #15.