adding GPL header and refactoring files