run time kernel manipulation, fixed some bugs