moved reference, amdloader, html2ts, templatecache into their own files

This helps with maintaininability. `ts.ts` is hereby a compilation (perhaps this should be moved out as well) + setting parsing only.