move defines.h to common.h
record ess before resample