Improve performance by removing some temporary objects
Fix some coding style issues
Add support for exiting formspecs by doubleclicking outside