Modularize state tracking

Separate mark stack state from main state module