Add/remove threading to clean up code