Minor refactoring and fix activity issue