New states, error handling, refactoring