Massive cleanup of file/script loading code