Added detrending. Minor fixes.