Finish the functions, added comentaries.