Refactoring. Changes for GUI interface