Some bugs corrected, some idea from Brauny (thx one more time)