Few additions and pep8 fixes

- Tracking flows locally in the database
- Added flows for gateways
- Added reverse flows