Removed more code duplication in the parser with some templates