Tidy up diary code a bit.