optimization, tidying and visual enhancements