Adding the code

Extensive refactoring is needed to reach a better and simpler
class/method structure.