improve docs for Function class and methods; provide code examples

also cleaned up whitespace