Implements background switching.