Re-oriented some models. Preliminary work on magnet script. Minor refactoring.