Fixes null reference crash on method serialization