improved frame parsing, support protocol v1