added init and MainLoop for running applications.