Fixed more sql statements and checked things work