Refactored, fixed background tasks