Some fixes but still has a horrible bug somewhere