Refactored.
Bug fix.