Fixes issues reported in #389