Fixed date bug, and cleaned up some code.