Fixed segfault under certain conditions.