Fix a bug with MainLoop. App API works now.
Add example of App API