Final clean-up. Added documentation.