Code refactoring. Callbacks were split up from main
Refactoring