Improve escaping (process backtick) and remove trailing spaces