general improvements and fixes