some improvements and patches