Added licenses and cleaned up some code