Modularized code now seems to be working.