Fixed up some functions