deals with NAs
new functions
small fixes