Some bugs fixed, others found.
Most of the bugs is due to my logic not being in the right order or not taken into account.