Numerous fixes and enhancements