A LOT of changes

Created HashSets that are passed by REF with locking for future
threading.