Updated functions, added documentation