Modularized the DOMs to allow for recursion.