Tag handling + various bugfixes