better error logging, fix possible bug on new instances