Engine dir - refactored according to phpmd and phpcs standards. There are some refactoring still required.