Port better timing code from ioq3