Added changes from Karl Dahlke.