Organize structure and fix variable access