added documentation support and did some re-arranging