Fixed docs. Fixed typo using global variables.
Fixed erroneous variable usage.