improved - made many variables/functions protected instead of private,
so that the extensions can access them.