Fixed a host of bugs and syntax errors.
Fixed some of the problems in viewing purchasing history, client-side.