few improvements and bug fixes