Code clean up and fixes

Hi
I made some clean up to the plugin and added a fix for issue #1

Let me know what you think

Thanks, Hernan