Made a number of changes to make it less ugly.