fixed errhandler, improved nano code