Refactor the widget

* Code standards
* Sanitise and escape all the things