Improvements and bug fix