Somewhat working version after OO refactor.