Several minor bug and feature fixes