Easy error handling in R (no loops) and some more functional programming tricks