improvements to date conversion function
cleanup some declarations
cleaned up comments
removed unnecessary allocations