Added some documentation and cleanup