Many refactors, introduction added