A bunch of improvements and fixes