Basic error checking and such