Added  Copyright  and some style/bug fixes