Tidy up code; add module pattern namespacing to client side scripts, remove unhelpful comments and log statements.