Use prepared statements in the Database library
Fixed and improved the Resource and Entity classes