Renamed main to client
More aggressive refactoring.

This enables static and client versions to more easily be kept in sync.