Code

Merging with changes made by Florian Foster.