Connection & Last Item ID problems fixed

There was a problem with the connection and with the Last item ID
function.