Ported existing mod loading code.