Bug fixes

issue number 1,3,4,6 fixes