Upload hangs if LCD display is connected to Reset pin

This the first mention of additional hardware (keypad) being attached.
So there are other things hooked up in addition to the glcd.
This is why I asked about other things being hooked up to the mega.

Sorry for not telling this. I had some things connected to my Mega and while investigating the problem disconnected everything, but forgot about the keypad.

Do you have a voltmeter?
If so check the VCC voltage and see if it is low particularly when the upload is failing.

Am I right that I should check the voltage between +5V and GND?
If so, I don't see changes when uploading code against when the code is normally run.
When the LCD sample is on I get 4.95V.
When Blink sample is run I get 4.80-4.86V. Don't know why it drops.
Without the display I get 4.99V.
However upload hanging seems random... It may occur when GLCD is run and I try to switch to Blink while voltage is still 4.95V. It may occur when I already run Blink (after BigNums) and try to re-upload Blink (at 4.85V). It may stop occurring in the last case with the same voltage. BTW disconnecting a single pin from the display (say, pin 22) doesn't seem to change voltage, though it seems to help to re-upload sketch after upload hangs and avrdude.exe is killed (but this may be just my thoughts, however it always helped me).

The glcd library is using pins 36 and 37 so you have pin collision,
which has the potential to create a short.
This is very bad.
Make sure you are not sharing any pins between the glcd library and the keypad.

I wanted to gather all the pins used by the display and the keypad together, so I changed some constants. Here's my modified version of ks0108_Mega.h (I hope this is the only file I need to modify):

/*
 * ks0108_Mega.h - User specific configuration for Arduino GLCD library
 *
 * Use this file to set io pins
 *
 * The configuration below uses a single port for data 
 * and has the same wiring as the mega config from the previous ks0108 library 
 *
*/

#ifndef GLCD_PIN_CONFIG_H
#define GLCD_PIN_CONFIG_H

/*
 * define name for pin configuration
 */
#define glcd_PinConfigName "ks0108-Mega"

/*********************************************************/
/*  Configuration for assigning LCD bits to Arduino Pins */
/*********************************************************/
/*
 * Pins used for Commands
 */
#define glcdCSEL1     30 // 33    // CS1 Bit  
#define glcdCSEL2     31 // 34    // CS2 Bit
#define glcdRW        32 // 35    // R/W Bit
#define glcdDI        33 // 36    // D/I Bit 
#define glcdEN        34 // 37    // EN Bit

//#if NBR_CHIP_SELECT_PINS > 2
//#define glcdCSEL3     32   // third chip select if needed
//#endif

//#if NBR_CHIP_SELECT_PINS > 3
//#define glcdCSEL4     31   // fourth chip select if needed
//#endif

/*
 * Data pin definitions
 * This version uses pins 22-29 for LCD Data 
 */
#define glcdData0Pin    22
#define glcdData1Pin    23
#define glcdData2Pin    24
#define glcdData3Pin    25
#define glcdData4Pin    26
#define glcdData5Pin    27
#define glcdData6Pin    28
#define glcdData7Pin    29

// Reset Bit  - uncomment the next line if reset is connected to an output pin
//#define glcdRES         30    // Reset Bit

#endif //GLCD_PIN_CONFIG_H

EDIT:
Looks like the problem might be connected with the keypad and constants reassignment. Whenever I disconnect the keypad completely I can't reproduce the hang. Connecting pins 36 and 37 of the keypad still produces no problem (I tried multiple re-uploads). But after connecting pin 38 along with 36 and 37 I got a hang. So there must be something else I need to change in GLCD in order to use reassigned pins...

EDIT2:
I think the problem is with pin 38. If I connect the keypad without it, everything uploads fine. With it I get hangs. Does this pin have a special meaning?

EDIT3:
If I connect a wire into pin 38, upload starts hanging. If I connect that wire to GND, everything starts working. Don't understand why...