Fixes and enhancements by Tarik