Re-organizing code, for cleanup