Fixed some bugs, some refactor and complete parser