Moved API around. Added much documentation.