various fixes and enhancement