More encapsulation and some other minor changes