Neatened up some code, made some style adjustments

As above.