More code removal and tidy of cred handling.