fixed some minor bugs. Some code needs cleanup

Anything that has anything need to do with emailing needs to be cleaned up,
moved, or redone for consistency and code maintainability.