Fixed some comparisons

Also some code style cleanup