restructure source layout, add some documentation