Added closures, better structured oobish code