Code to handle some weird siutations and bad WIMs