Refactored to be in sync with master