Update API documentation
Refactor code