Split parser to .h and .cpp and refactor it