Restructuring and better error handling.