Improved performance of lightning and made some minor changes.