Improved simplifying afs program