Fixes #218 and another bug