Added more functionality to "kernel" and removed some bugs.