Various code improvements and README.md typos correction