More Git optimizations

See commits for details.
(the fix for 138 is not yet in this batch)