Move parsing and some refactoring