add comments, add output for failure case, remove debug code and opengl display.