added copyright and code clean-up