Clean up and add function annotations.