Add some const qualifiers and friends.

Let's see if this helps with speed.