Inline misc functions
Comment and tidy code, esp. headers.