added documentation, general overhaul