trainer UI work and moving more PHP into client-side JavaScript