fixes and comments to improve coding style