Fixed switching between tools. Code refactoring.