Remove global temporary count.
Replace ternary max with macro.