some changes towards simplifying C extension interface (not finished yet).