structural changes, added some documentation