Document functions and add explicit types.