fixes and performance tuning