Fine tuning and bug fixes