Another attempt at text formatting - still buggy, but close