Added messageBox, fixed thread bugs