Fixed some functions