Remove global constants.
Completely redo map SQL.
Code standards fixes.