Improved documentation
Also removed unnecessary variables passed to functions