Load themes as soon as possible to avoid FoUC

Also move theme configuration slightly to avoid sever-side caching bug