First final version

1 still needs to be reworked more carefully.