Adding recovery code in case of error
Fixing compilation errors