Almost final, just need to fix the exit problem