API cleanup and some documentation.