Refactoring status handling to fix bugs.