Refactored a lot to introduce encapsulated memory to remove state from SpatialPooler