Mostly finished AutoFormat.java - a few bugs left.

Am commiting before attempting to fix by mass deletion of code.