adding apple doc comments, copyright, and nil checks