Serious clean up of the amd loading system.