added copyright and code cleanup