fixed NPE in fields -> default values code, made it a bit smarter and more robust