Correcting the thread synchronization issues. Not optimal but working.