Moved ui framework loading to head

- Also tried to make fixes