Fixed small bugs with monomial sorting