fixes #349, #194, also code changes toward fixing #66