Added fixes for app being used out of context.

    * Added bugfix for app being out of context