Made things thread safe and improved GUI's speed