Translated by Google, plus a few cleanups