A few const correct and passing by reference instead of copy changes.