final form

This MAY BE the final form of the code. Last thing left is to devide it
in two parts