Refactor a bunch of runtime lib loading to new file