Major API updates and coding cleanup. Still work in progreess