common: add min/max macros
fix crap move bug

caused by timing