Add timeouts to functions that can timeout.  Add the functions application_running and application_loaded.