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

Also made some cosmetic changes.
Closes #11
Closes #12
Closes #22