Repaired segfaults reported by Alexandre Reber