Fixes merge conflicts for issues #346 #343 

This will replace merge request #347 that fixes issue #346 and request #345 that fixes issue #343.