Added some documentation and checks