Fixes to make it run

Runs now, but doesn't bring expected result.