Fleshed out main, some HLint-inspired tidy up