cut duplicated code, move some methods to parser
merge conflicts