Tidy up includes. Declare functions static where needed. Fix html declaration element bug.