Fix wallpaper thread lockups and whitespace

My previous fix used some unnecessarily complicated code, and caused occasional lockups due to timing. That won't happen anymore.