refactor code into seperate files.

can now redirect and 'new' notebook request