tidy up extensions parsing code