Several enhancements and bugs fixed