Improved preprocessing step, working towards #89.