Fixed tag-generation. Does need testing though...