Cleaned up functions that had been moved to other modules and added a few comments