Refactor handles module for readability