Ported files from matthewgraybosch.com.