Replaced preparation function with modularized code, along with any necessary functions it calls, removed old preparation code