Fixed various bugs pertaining to the refactor.