improvements and debug