Minor improvements and bugfixing.

Improved code ordering, so that js matches html.
Fixed issues with group policies not updating correctly.