cleanup mad code for 64-bit