Added tagging support and fixed a few bugs