various code corrections thanks to webstorm inspector