included the changes by fgsl (#4660)