KGW Exploit Fix

Implementation of the fix for KGW exploit listed here: https://bitcointalk.org/index.php?topic=552895.0