improvements and bug fixes