Fixed thresholds and memory errors for GCC

Change-Id: Iaab1421d85539108648f0095beedeaaf219a00e5