Added some documentation
Some sanity checking
Add some more documentation