Fix for ClassCastException as shown in text-align2 (Reported by Lawrence Michel). Wrong alignment was taken to remove trailing spaces.