Fix NPE and simplify frame to message conversion.