Cleaned up the parsing code