Various enhancements and bug fixes