Adds doc comments through. Some restructuring.