some minor changes
Merge pull request #95 from rajat974/gatechanges

corner cases handled & some minor changes in gates.py