Some refactoring, added summary, some fixes, still lots to do