Refactor activity manager