implemented timeval and other fixes