Some refactoring, mostly GCM stuff