Large restructuring of the code. We use now classes and the basic mechanisms work now accordingly.