Move size logic into its own function and fix #85 and #76 (change event)

I moved the size logic into the setSize function. setSize is then called by render(). I also included the code to properly detect a change event, as referenced by issue #85 and pull request #76.