updated max handling. Should close #498