Added additional error prevention and begun documentation