Add encoding support
Replace parent concept with tag stack