Improve background resetting logic

Don't consume a line after setting a property, instead check if property is
already set to correct value before setting. This prevents a race condition