added router code, fixed a few things