Refactoring the frame parsing