Modularizing; probably introducing new bugs-- untested yet.