Minor changes.
Made it work with Threading.