Starte refactoring code.
Fixed code to work again with refactored system.