Fixed error in autocal, cleanup

Fixed error in autocal that caused it to not really work.