cleaned up parsing logic and structure.