Save instance on form submit
Small code layout improvements
Refactor, prevent globals and conflicts