Fix some bugs in monad-unify, and make use of FlexibleInstances