Refactoring, fixes tests & set null for base key by default.