updated derived vars - new error handling, some data.table implementation