Cleaned up comments, fixed a small bug if error occurred.