Refactor specparser.py