Fixes for #289 and #186

This fixes #289 and #186
(Sorry for two fixes in one PR)