Fixes for #142 and #146

This is meant to fix #142 and #146