Improved error handling for the ACU, cleaned code