Many improvements and fixes