Some changes to the functions.sql