Add start of documention
Add some more error checking for parameters