various fixes and enhancements

please review