fix synchronization for background handling. also add logging for background. Still work in progress.