Some bugs fixed and the code is more clear...