In do flash unified the time which has gone by before uploading using the port in which Leonardo board was connected.
Added flag isAvrdudeRunning = false when Leonardo could not auto-reset.