private static int doTimedEvents( int firedEvents, long startTime )
    {

        Iterator< Event > it = timedEvents.iterator(); // get the iterator for the timed events
        while ( it.hasNext() )
        {
            if ( TimeHelper.isOver( startTime, MaxTickTime ) )
            {
                return firedEvents; // we've run out of time for this tick, let's keep the game running
            }
            Event e = it.next(); // get the next event

            // if the timed events are throttled too, then we may have to break out of the loop
            if ( TimedEventsThrottled && ( firedEvents >= MaxEvents ) )
            {
                break;
            }

            // everything past this point will have a higher execution time than this one as well, and we haven't gotten to this time yet
            if ( e.executionTime > Sys.getTime() )
            {
                break;
            }

            try
            {
                e.action.invoke( e.target, e.parameters ); // invoke the method
                if ( TimedEventsThrottled )
                {
                    firedEvents++;
                }
            }
            catch ( Exception ex )
            {
                Lumberjack.error( "Scheduler", "Failed to invoke \"%s()\"", e.action.getName() );
                Lumberjack.throwable( "Scheduler", ex );
            }

            if ( LogOutput )
            {
                Lumberjack.debug( "Scheduler", "Executed timed event \"%s\"", e.action.getName() );
            }

            it.remove(); // remove the iterated objects
        }

        return firedEvents;
    }