Added licence, some restructuring