many layout fixes and clean-ups as well as optimizations