better escaping + some validations in parser and generator