fix max() => min()
also add a few spaces
change colors, also add the comments from the Wiring code to the Javascript