First complete version; not yet tested

Change-Id: Ia620cfa96c1c093b69731d92eee81a4291d93f4e