Finished basic implementation

The problem is that I'm not 100% sure everything is working because the
networks are so complex. Further testing is required, but for now it
runs without error.