Fixed bug (helpfully I'd left a comment anticipating the problem).
Comments, WS, names, formatting.