Added further documentation and fixed error created while cleaning up the code.