Background modeling refactored