Fixes some bugs related to #20, closes #19