fixes #1330 and #1297