R wrapper and tweaks to preprocessing script