further cleaning up of parsing code