Refactoring in maze generator library