Added more robust error checking on methods.