Code cleanup; fix compare function when values are null