Add appledoc generation and start documenting.
Additional code cleanup.