Small tidy up

Document some code and remove unused vars