Fixes discovered bugs

- If the input or button was not a direct child of a td the plugin had issues
- Also optimized index calculation