lots of refactoring and making the API lean and mean