Improved feedback by checking whether things went right instead of assuming it.

Also added some comments to explain what is happening and some empty lines
for better readability.