general bug fixing and cleaning-up of code with tags