Closes #580, fixes #506