Two comparison bugs fixed

This pull request also includes the changes from #1.