Some fixes and enhancements