some fixes and enhancement