Correctly handle drawing groups within an embedded shape

Fixes #886 and #887