Added error checking and formatting goodness.