Separated out wavelet code