Misc fixes to extension loading code.