0.12 six commit

clean some code, complet rewrite of some parts, enhance lisibility.
0.12 seven commit