More work with tags. Some optimization.