Moved random generator inside Memory class