Patterns refactoring (better encapsulation, more docstring)