Now it looking much better. Small refactoring were done and comments were added.