Various fixes and addition of PR #891