Port Snapping defect

There is a defect with port snapping boundary calculation. 
The defect is mainly with ports with one INPUT or more than 2 INPUT. 

Fixed the boundary calculation and also there was a bug in checking the flag condition. 

- [ ] @pboyer