integrated compareSpectra, fixed some bugs