fix constant escaping and make sure we have a valid constant