Use uid rather than user keyword consistently.
Formatting and add some TODOs or commnts.