Small code restructuring.
Updated documentation.