Refactored API. Added docs