Cleaned up statemachine syntax and finished statemachine mapping.