Strip new lines from messages and replaces them with spaces.
Various changes and bug fixes