Add some right-click functionality and clean up code.