add few bug fixes as requested