Moving message handling to client