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. I also fixed the whitespace in my code (spaces, not tabs).