add debug flag
extend parsing logic to better recognize tags