code re-factored.
Unstable commit.