fixes #805 and #281