Delete operation added. Improved error handling a bit.