Added back in Charles Nutters modifications ready for invoke dynamic.