rearranged some stuff, added documentation