Somehow fixed IM definition.  Move random matrix generator outside.