Fix crash when using list layout (#68).

Fixes #68 which was caused all sorts of nasty crashes. The fix was found and suggested by @mrjjwright in the mentioned issue.