Added some comments and fixed a type.