Fixed ImageRecord by path query
Clean up prepared queries when database object is destroyed
Replaced ImageRecord query with prepared version
Moved creation of prepared statements to correct function
Replaced normal query for Imagerecord with prepared version
Added catch clause for adding records