move defines to params.h; refactor