Some small performance improvements from Thomas Kopp.