Better approach to split lines. Fixes bug #4618