Fixes issues pointed by @mkroehnert