Refactored kernel.py into 5 separate modules.