Added license file and next round of changes/refactorings.
Next round of refactorings and improvements.