More fixes to libdir detection