Fixes to UserDetails model, related lookup models, and related SQL scripts.