Incorporated simchrs refactoring with minor changes that fix the cause of error