Big cleanup of functions, fixing features, templates to make theme checker happy