Make API more type-safe with explicit key types.

Also improve documentation.

Signed-off-by: Austin Seipp <aseipp@pobox.com>