Created skeleton of router code, made some bugfixes.
Merge.