Refactorings, documentation, cs fixes