Fixes based on Andreas' suggestions