Several bug fixes. See CHANGES.md