Found a few last functions that need changing to native SQL