refactoring to more formal frame parsing.