Back end changes to use custom SQL