Fixed text wrapping to happen on spaces and did a bit more refactoring.

Closes #22