fully fixed leading and trailing space errors
improved debug functions