remove dead code and re-arrange existing code
adding copyright and license