Updated functions, better SQL injection prevention