Added some better API message handling.