gcc 4.6 build fixes and memory access error bug fixed