Issue #11: Fixes in function docs.

Added extra checks for the presence of variables.
Fixed some bugs.