Added threading and moved to Service.