Cut down code actually works now, next step=profiling