Documentation

Added documentation for some functions
Restructured variable names in some functions