Fixed JavaScript bugs

- Removed redundant code
- Fixed bugs in Endpoint settings editor