Refactor modals

Initiates modals from templates rather than DOM elements.