Use pthread_join instead of polling
Fix args library memory issue