Minor tidyup, some use of >>= and applicative style.