optimize finding backslash at end of line + cleanups