Did some refactoring and added the gpl license