better error handling and design tweaks