Kernel/Model patches and add unit tests