cleaned up some code, added better documentation to undocumented areas

should be good to go