Refactored activitysystem code