updated a lot of code in API and added beginning of API doc