Applied various commits by Paul L.