Working version. Some parts need improvement. Further tests must be done. Added more networks to test.