comment + fixes

fixes:
errors management
minor changes  on code structur