Refactor bleach and separate IO into utils