General code review adding missing behaviors (according to the
specification). And Refactoring.