Generate proper model names when dealing with uppercase tablenames.

Pull request for #3449