Reorder checks, replace bitwise with logical ops.