Host enumeration performance optimisations

Port fixes made on trunk to xs64bit.