SQL Prepared Statements Fix

Fixed the prepared statements, currently doing a group code review