replace confusing and incorrect cleanup logic
move initialization logic into state control function
consolidate redundant initialization logic