Further general improvements and cleanup.