improvements and bug corrections