Improvements and bugs fixing