Big clean up and API changes