added, prevent the app from sleeping during monitoring + some refactoring