Re-structured preprocessing functions