Issue217

Fixes #217 and #263