Refactor state machine; start handling append entries