code cleanup and renaming, adding date functions