Fix wrt. reloadui

Moved around some code to fix issues with /reloadui and SYNC.