Applied feature #3375 and fix of pull 1842 to avoid merging problems later