Refactored machine token creation and rendering code to remove duplication.
Fixed disabled links still working due to events not attached properly.