Minor changes and code optimization