Added more robust implementation of chrome-removal code.