Try to make convoluted code a little more coherent.

Also use equal? in a few more places