fix bugs spoted by Jay

Jay required fixes are done