migrated to OO style, bugfixes