Removed duplicate kernels, slightly modified API for Python compatibility.