Some refactoring, speedup, added execute.