Code cleanup

The license in the plugin portal said Apache 2, so I added the appropriate license header to source files. Some source files used tabs and some used spaces, so I standardized and converted all to use spaces. Also some minor cleanup in the actual code.