Implemented lightning hook using ASM.

Reorganized core.