Beginning to add comparison function

This pull request comes with various fixes as well.