[TASK] Refactoring and cleanup