Added const correctness and comments.