improve loading logic / re-use existing loadlibrary routines in core