Modularizing code in preparation for implementation in ZD