tuning and bug fixes