Some fixes from arduino forums from user El_Supremo