Refactored bug fix.