Implements #1165
Implements #1166
Work on #1152
Merge pull request #1167 from emmanuel-keller/1.6

Bug fixes and improvements