Initial upgrade to 3.1

Most of the basic work completed and works in 3.1. Needs work on the Javascript in the admin.