Mainly some stuff for extracting spectra