Several small improvements and fixes