Slightly refactored and added license