Fsm fixes

Ported fixes from my spawn_work branch for the FSM subsystem to reduce CPU consumption.

As a side effect some of the spawn stuff has been included. This will be modified/removed in future commits that involve spawning.