Split functions to different files, added documentation