Fix preemptive scheduling.
Fix exception handling and context switching