fix fatal error on metadata missing and minor others fixes