improvements and bugs fixed