Improve parsing code