Eliminate duplicate tag parsing code

Signed-off-by: Pekka Enberg <penberg@iki.fi>