Added offset and max. Made select statements prepared statements