Some refactoring and fixed MonadReader local.