added more min, max, avg functions to calc and fixed more problems