Added back some more code with modifications.