Code

Update from Uwe Schoeler, with corrections by myself. Not yet finished.