smartmax: add unified implementation from maxwen