Refactor API message handling code