Fixed refactoring-introduced SEGFAULT