Moved maze generation routine