some improvements and fixes