Preprocessing and score functions