Some improvements and fixes