Refactored owinContext and commented javascript