improve tag performance

This stores tags as sets instead of arrays and tries to maintain serialization compatibility.