Refactoring the handler system