Fixed variable storing, added debug lines to tag trace.