Fixed bug in taghandler. Resolves #516.