Switched perception and memory to sets, and removed the unused previous_perception