Merge bug fixes contributed by Michael Abmayer.