Re-organised stuff and re-wrote TESF