Cleaned up, based on comments by eecolor.