Minor code cleanup

Replace nested if-then-else and progn-blocks with a cond (which has the
same control flow and implicit progns)