Make some arguments const, and some stylistic improvements