Add documentation and remove naming inconsistencies.
Proper bounds checking for line break positions.
Closes #2037.