replace INT_MAX by proper typedef
minor edit
apply some more constness