Added functions
Some fixes to functions