Commit finished some refactoring and pattern clearnes.