some format related cleanup and some minor escaping when executing shell commands