Multiple improvements

Awesome work! I have extended it with some of my own which I use in projects. Please review and accept if you find this useful.