Updated with some documentation and reorginzation