Code clean up and license headers