General improvements and fixes