Added code for initialization of the functions, edited some comments