Fixed issues with OWIN setup.

See comments in the code to understand what was changed and why.
Merge pull request #1 from tillig/master

Fixed issues with OWIN setup.