backport changes made to Google project to my fork here