Second big commit

Second big commit after real tests.