diff --git a/Projects/AVRISP/Lib/V2Protocol.c b/Projects/AVRISP/Lib/V2Protocol.c
index 3a1b78efd1dd2806090f3d3d3eee2250014af27f..3aa2d89cad9cfa7e59af4d3346a256bc3d59dd99 100644
--- a/Projects/AVRISP/Lib/V2Protocol.c
+++ b/Projects/AVRISP/Lib/V2Protocol.c
@@ -308,6 +308,18 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
 
 	Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));
 	Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
+	
+	if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))
+	{
+		Endpoint_ClearOUT();
+		Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
+
+		Endpoint_Write_Byte(V2Command);
+		Endpoint_Write_Byte(STATUS_CMD_FAILED);
+		Endpoint_ClearIN();
+		return;
+	}
+	
 	Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite);
 
 	Endpoint_ClearOUT();
@@ -407,7 +419,6 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
 
 	Endpoint_Write_Byte(V2Command);
 	Endpoint_Write_Byte(ProgrammingStatus);
-	
 	Endpoint_ClearIN();
 }
 
diff --git a/Projects/AVRISP/Lib/V2ProtocolTarget.c b/Projects/AVRISP/Lib/V2ProtocolTarget.c
index 9c6ccf4c62581ddb59aff927f84fe88b3c5522d5..24cd941a4a10a48cfb0d21c1d6371bd3bed85207 100644
--- a/Projects/AVRISP/Lib/V2ProtocolTarget.c
+++ b/Projects/AVRISP/Lib/V2ProtocolTarget.c
@@ -155,13 +155,15 @@ uint8_t V2Protocol_WaitWhileTargetBusy(void)
 {
 	TCNT0 = 0;
 	
+	bool DeviceBusy;
+	
 	do
 	{
 		SPI_SendByte(0xF0);
 		SPI_SendByte(0x00);
 
 		SPI_SendByte(0x00);
-		bool DeviceBusy = (SPI_ReceiveByte() & 0x01);
+		DeviceBusy = (SPI_ReceiveByte() & 0x01);
 	}
 	while (DeviceBusy && (TCNT0 < TARGET_BUSY_TIMEOUT_MS));
 
diff --git a/Projects/AVRISP/Lib/V2ProtocolTarget.h b/Projects/AVRISP/Lib/V2ProtocolTarget.h
index 1e0364d9ccfa77a2cc8eeb0b270ac0a0d12eb52f..6322b9f3366f99d0486eef06fabc8ba842e9ff99 100644
--- a/Projects/AVRISP/Lib/V2ProtocolTarget.h
+++ b/Projects/AVRISP/Lib/V2ProtocolTarget.h
@@ -52,7 +52,7 @@
 		#define TOTAL_PROGRAMMING_SPEEDS  7
 
 		/** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */
-		#define TARGET_BUSY_TIMEOUT_MS    150
+		#define TARGET_BUSY_TIMEOUT_MS    240
 		
 	/* External Variables: */
 		extern uint32_t CurrentAddress;