Rewrote the function AutoSetParameters().