Fixed crash due to incorrect allocation of NSDate. Fixed some logical errors from the OS X 10.8 update.