Added debug code and parameters for functions