small fixes, performance tuning