Major code refactor

The problem wsa not properly engaged, and we needed to throw most of our code to the
trash and think again all the models and the structures and how the rules are applied
in out specific problem.