layout and encoding fixes