add GPLv3+ text to source files
code cleanups and more comments