fixes to preprocessing functions