fix handling of too many portals. also make it dependant on visible portals only