documentation and some optimization
cleanup