Fixed bugs after testing with avinash's client