PLA-793 change triming and handling newlines