made a few fixes to preprocessing logic