Bit of tidy up and made a couple of things a little more robust.