Fix runtime exception/segfault in method calls