A number of improvements and fixes