begin to clean the code, add some documentation
work in progress ....