Better error logs and simpler code