More robust error messages

Also cleaned up comments a bit more and renamed some stuff