Fix SQL and finish "Received Files" functionality