Merge "move clear_system_state() call before using double"