Closes issue #1333 and #1342