Removes excess code and normalizes "ties"