Fixes #2 and a few other cases