Improve capturing regex and fix sorting alignment values.