some enhancements

hello,

please review

if you like come commits, and some not, i can separate to several pull requests, if it would take me a lot of time to adjust the changes

have a nice day