Functions almost done, missing SQL ones