Tidy-up and fix bugs in stylesheet loading

* Tidy up stylesheet loading & HTML head generation
* Simplify layout view header code