The only way I can think of to fix this somewhat gracefully is to split the third "page", where the message actually gets inserted into the database, into it's own file. That way I can always treat the incoming message as a string, and I can work with it to do what I need to do. Any better suggestions?