a batch of small improvements and bug fixes