complete recode

OOP support, added a few apis and deleted all old code.