Some changes to make it sqlite compatible