Added comments and attribution.
Changed the way that icon state is calculated to remove javascript calls - now it directly looks at the state of the node instead of calculating something.