multiple improvements and minor bugs fixes