Preparation of nitrogen-containing organic compounds