fixes #784 and #786