Refactor control message handling