Word wrap algorithm. This is terrible. I'm sorry.