Bug fix and preformance increase