Optimized threading

Release 0.5.2