Saner error checking and some renaming