Some stats changes and modified termination condition