several enhancements and bug fixes