add documentation && minor refactors