Implemented changes suggested by tdanford.