Added root functions and more cleanup.