k-mode refactoring