Fix threads and object deletion in application.