more improvements and bugs