Added documentation and made some small modifications.