Added licenses and fixed bugs