Added safety stop code.