Better removeEmpties function, fixed Engine regexps