Coco bug fixes

fixes #368 and #361