improved handling of lib loading