Initial commit. Ported from the original codebase.