Add more exception handler and some other functions