Refactor portal logic to remove concurrentmodificationexception when locking portals, and fix a bug where locking portals linked cave and surface together